package kr.couponplay.android.support;

import java.io.InputStream;

import kr.couponplay.android.Constants;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;

public class StaticMapUtils {

	public static Bitmap getGoogleMapThumbnail(String lati, String longi, int width, int height) {
		//http://maps.googleapis.com/maps/api/staticmap?center=37.59095190,127.01708200&zoom=15&size=400x200&markers=color:blue|label:S|37.59095190,127.01708200&sensor=false
		StringBuffer sb = new StringBuffer();
		sb.append("http://maps.google.com/maps/api/staticmap");
		sb.append("?center=" + lati + "," + longi);
		sb.append("&zoom=16");
		sb.append("&size=" + width + "x" + height);
		sb.append("&markers=color:blue%7C" + lati + "," + longi);
		sb.append("&sensor=false");

		Bitmap bmp = null;
		InputStream in = null;
		try {
			in = HttpUtils.executeToIn(sb.toString());
			bmp = BitmapFactory.decodeStream(in);
			in.close();
		} catch (Exception e) {
			Log.e(Constants.TAG, e.getMessage(), e);
		}

		return bmp;
	}
}
